<table class="automations">
  <thead>
    <tr>
      <th></th>
      <th>{{i18n "discourse_automation.models.automation.name.label"}}</th>
      <th>{{i18n "discourse_automation.models.automation.trigger.label"}}</th>
      <th>{{i18n "discourse_automation.models.automation.script.label"}}</th>
      <th>{{i18n "discourse_automation.models.automation.last_updated_by.label"}}</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    {{#each model as |automation|}}
      {{#if automation.script.not_found}}
        <tr>
          <td colspan="7" class="alert alert-danger">
            {{i18n "discourse_automation.scriptables.not_found" script=automation.script.id automation=automation.name}}
          </td>
        </tr>
      {{else if automation.trigger.not_found}}
        <tr>
          <td colspan="7" class="alert alert-danger">
            {{i18n "discourse_automation.triggerables.not_found" trigger=automation.trigger.id automation=automation.name}}
          </td>
        </tr>
      {{else}}
        <tr>
          <td role="button" {{on "click" (fn this.editAutomation automation)}}>{{format-enabled-automation automation.enabled automation.trigger}}</td>
          <td tabindex="0" role="button" {{on "keypress" (fn this.editAutomation automation)}} {{on "click" (fn this.editAutomation automation)}}>{{automation.name}}</td>
          <td role="button" {{on "click" (fn this.editAutomation automation)}}>{{if automation.trigger.id automation.trigger.name "-"}}</td>
          <td role="button" {{on "click" (fn this.editAutomation automation)}}>{{automation.script.name}} (v{{automation.script.version}})</td>
          <td>
            <a href={{automation.last_updated_by.userPath}} data-user-card={{automation.last_updated_by.username}}>
              {{avatar automation.last_updated_by imageSize="small"}}
            </a>
            {{format-date automation.updated_at leaveAgo="true"}}
          </td>
          <td>
            {{d-button
              icon="trash-alt"
              class="btn-danger"
              action=(action "destroyAutomation" automation)
            }}
          </td>
        </tr>
      {{/if}}
    {{/each}}
  </tbody>
</table>
